package com.sun;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularTest1Group {
    public static void main(String[] args) {
        Pattern pattern = Pattern.compile("^(\\d{3,4})\\-(\\d{6,8})$");
        Matcher matcher = pattern.matcher("010-12345678");
        if(matcher.matches()){
            String whole = matcher.group(0);
            System.out.println(whole);
            String areCode = matcher.group(1);
            System.out.println(areCode);
            String telNumber = matcher.group(2);
            System.out.println(telNumber);
        }
    }
}
